<?php

/**
 * This is the model class for table "tbl_tipodoctec".
 *
 * The followings are the available columns in table 'tbl_tipodoctec':
 * @property integer $id
 * @property string $DocTecnica
 * @property string $Campo01
 * @property string $Campo02
 * @property string $Campo03
 * @property string $Campo04
 * @property string $Campo05
 * @property string $Campo06
 * @property string $Campo07
 * @property string $Campo08
 * @property string $Campo09
 * @property string $Campo10
 * @property integer $idProj
 */
class Tipodoctec extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_tipodoctec';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('idProj', 'numerical', 'integerOnly'=>true),
			array('DocTecnica', 'length', 'max'=>20),
			array('Campo01, Campo02, Campo03, Campo04, Campo05, Campo06, Campo07, Campo08, Campo09, Campo10', 'length', 'max'=>30),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, DocTecnica, Campo01, Campo02, Campo03, Campo04, Campo05, Campo06, Campo07, Campo08, Campo09, Campo10, idProj', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'DocTecnica' => 'Tipo de Documentação Técnica',
			'Campo01' => 'Campo01',
			'Campo02' => 'Campo02',
			'Campo03' => 'Campo03',
			'Campo04' => 'Campo04',
			'Campo05' => 'Campo05',
			'Campo06' => 'Campo06',
			'Campo07' => 'Campo07',
			'Campo08' => 'Campo08',
			'Campo09' => 'Campo09',
			'Campo10' => 'Campo10',
			'idProj' => 'Id Proj',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('DocTecnica',$this->DocTecnica,true);
		$criteria->compare('Campo01',$this->Campo01,true);
		$criteria->compare('Campo02',$this->Campo02,true);
		$criteria->compare('Campo03',$this->Campo03,true);
		$criteria->compare('Campo04',$this->Campo04,true);
		$criteria->compare('Campo05',$this->Campo05,true);
		$criteria->compare('Campo06',$this->Campo06,true);
		$criteria->compare('Campo07',$this->Campo07,true);
		$criteria->compare('Campo08',$this->Campo08,true);
		$criteria->compare('Campo09',$this->Campo09,true);
		$criteria->compare('Campo10',$this->Campo10,true);
		$criteria->compare('idProj',Yii::app()->user->pidproj);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Tipodoctec the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
